import request from "@/utils/request";
import {MealCenterRequest, MealCenterResponse} from "@/api/types/mealCenter";
import {BaseResponse} from "@/api/types/baseResponse";

// 公用的 API 地址
const URL = "/system/mealcenter"

// 查询所有的出餐中心
export async function getMealCenters() {
    return await request.get<BaseResponse<MealCenterResponse[]>, BaseResponse<MealCenterResponse[]>>(URL)
}

// 根据ID查询出餐中心
export async function getMealCenterById(id: number) {
    return await request.get<BaseResponse<MealCenterResponse[]>, BaseResponse<MealCenterResponse[]>>(URL, {params: {id}})
}

// 增加出餐中心
export async function addMealCenter(data: MealCenterRequest) {
    return await request.post<BaseResponse<[]>, BaseResponse<[]>>(URL, data)
}

// 修改出餐中心
export async function updateMealCenter(data: MealCenterRequest) {
    return await request.put<BaseResponse<boolean>, BaseResponse<boolean>>(URL, data)
}

// 根据ID删除出餐中心
export async function deleteMealCenterById(id: number) {
    return await request.delete<BaseResponse<boolean>, BaseResponse<boolean>>(URL, {data: {id}})
}
